// #include <stdio.h>
// #include <stdlib.h>

#include <iostream>
#include <fstream>

#include "init/parse_args.h"
#include "init/load_img.h"
#include "exec/npc_exec.h"
#include "dpi/dpi.h"
#include "sdb/sdb.h"\
#include "diff_test/diff_test.h"
using namespace std;
extern char *log_file ;
#ifdef FTRACE
  extern char *elf_file;
#endif
extern char *diff_so_file;
extern char *img_file;
extern int difftest_port ;
extern void diff_test();
#ifdef DIFFTEST
extern void init_difftest(char *ref_so_file, long img_size, int port);
#endif
#ifdef VGA
extern  void init_screen();
#endif
#ifdef KEYBOARD
extern void init_keymap();
#endif
// extern long load_img();
// extern void init_log(const char *log_file) ;
// extern void add_elf(char * file);
extern uint64_t get_time();
int main(int argc, char *argv[]) {
	parse_args(argc, argv);
	long img_size = load_img();
	init_log(log_file);
#ifdef VGA
	init_screen();
#endif
#ifdef KEYBOARD
	init_keymap();
#endif
#ifdef FTRACE
	add_elf(elf_file);
#endif
	creat_Context();
	
	rst();

#ifdef DIFFTEST
	init_difftest(diff_so_file, img_size, difftest_port);
#endif	
 	sdb_mainloop();
 	delete_Context();
	return check_state();
}